package com.dldata.devtools30.service.api;


import com.dldata.devtools30.entity.DevtApiSubEntity;
import com.dldata.devtools30.repository.api.DevtApiSubEntityDao;
import com.google.common.collect.Lists;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created by ai on 2017/1/11.
 */
@Component
@Transactional
public class DevtApiSubEntityService {
    @Autowired
    DevtApiSubEntityDao devtApiSubEntityDao;

    public List<DevtApiSubEntity> getAllDataById(String mainid) {
        return devtApiSubEntityDao.getAllDataById(mainid);
    }

    public List<DevtApiSubEntity> getAllData() {
//        return pFunctionSubDao.getAllCloneData();
        return Lists.newArrayList(devtApiSubEntityDao.findAll());
    }

    public List<DevtApiSubEntity> getOneData(String id) {
        return devtApiSubEntityDao.getOneData(id);
    }

    public List<DevtApiSubEntity> getOneDataByMainid(String mainid, String dm) {
        return devtApiSubEntityDao.getOneDataByMainid(mainid, dm);
    }

    public List<DevtApiSubEntity> getOneDataByDm(String dm) {
        return devtApiSubEntityDao.getOneDataByDm(dm);
    }

    public List<DevtApiSubEntity> getOneDataByMcAndId(String mc, String id) {
        return devtApiSubEntityDao.getOneDataByMcAndId(mc, id);
    }

    public List<DevtApiSubEntity> getOneDataByDmAndId(String mc, String id) {
        return devtApiSubEntityDao.getOneDataByDmAndId(mc, id);
    }

    public DevtApiSubEntity save(DevtApiSubEntity pfEntity){
//        return  pFunctionSubDao.save(pfEntity.getId(),pfEntity);
        return  devtApiSubEntityDao.save(pfEntity);
    }

    public void delete(String id){
        devtApiSubEntityDao.deleteById(id);
    }


    /**
     *<!--替换拼接就是tjsql里面直接替换#values# sql里面#name#替换tjsql -->
     *<!--预编译就是tjsql里面直接替换#values#后作为预编译SQL参数 sql里面#name#替换? sql配置为and name like #name#  tjsql则为 '%#values#%'-->
     */
    public static enum sqltype{
        replaceconcat,precompile,nameprecompile;
    }
}
